import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/deliver/views/deliver_select_box_info.dart';
import 'package:honeypotflutter/modules/deliver/views/deliver_select_header.dart';
import 'package:honeypotflutter/public/public_baseState.dart';
import 'package:honeypotflutter/public/public_total.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/router/bussine_router_url.dart';
import '../../views/deliver_select_account.dart';
import 'logic.dart';

class DeliverSelectPage extends StatefulWidget {
  const DeliverSelectPage({Key? key}) : super(key: key);

  @override
  State<DeliverSelectPage> createState() => _DeliverSelectPageState();
}

class _DeliverSelectPageState extends HLBaseState<DeliverSelectPage> {
  final DeliverSelectLogic logic = Get.put(DeliverSelectLogic());
  String? qrResult;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    qrResult = Get.arguments;
    logic.requestDeliverBoxInfo(qrResult);
  }

  /*
  * 返回
  * */
  void didPopNext() {
    bool change = Get.arguments;
    if (change == true) {
      logic.requestDeliverBoxInfo(qrResult);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "选择格口"),
      body: HLScrollView(
        padding: EdgeInsets.only(left: 12, right: 12, top: 16),
        children: [
          DeliverSelectHeader(action: () {
            HLTotal.total("deviceID注意");
            Get.toNamed(MGRouterUrl.package_retention, arguments: 1);
          }),
          DeliverSelectAccount(),
          DeliverSelectBoxInfo(),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<DeliverSelectLogic>();
    super.dispose();
  }
}
